//
//  LGECGDetailRiskCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2024/8/20.
//

#import "LGECGDetailRiskCell.h"

@interface LGECGDetailRiskCell()
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UILabel *statusLabel;
/**   */
@property (nonatomic , strong)UILabel *valueLabel;
/**   */
@property (nonatomic , strong)NSDictionary *colorDic;
/**   */
@property (nonatomic , strong)NSDictionary *statusDic;

@end

@implementation LGECGDetailRiskCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.colorDic = @{@"0":@"#5E8EF5",@"1":@"#FE6603",@"2":@"#C14D4D"};
        self.statusDic = @{@"0":@"低风险",@"1":@"中风险",@"2":@"高风险"};
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    [super setDataDic:dataDic];
    NSString *status = LGNSString(dataDic[@"status"]);
    self.titleLabel.text = LGNSString(dataDic[@"title"]);
    self.statusLabel.text = self.statusDic[status];
    self.statusLabel.textColor = [UIColor colorWithString:self.colorDic[status]];
    self.valueLabel.text = [NSString stringWithFormat:@"%@%%",dataDic[@"value"]];
    self.valueLabel.textColor = [UIColor colorWithString:self.colorDic[status]];
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.statusLabel];
    [self.contentView addSubview:self.valueLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(viewPix(10));
        make.left.equalTo(self.contentView).offset(viewPix(28));
        make.bottom.equalTo(self.contentView).offset(-viewPix(10));
        make.right.equalTo(self.statusLabel.mas_left).offset(-viewPix(10));
    }];
    [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView.mas_centerX).offset(viewPix(10));
        make.centerY.equalTo(self.titleLabel);
    }];
    [self.valueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-viewPix(28));
        make.centerY.equalTo(self.titleLabel);
    }];
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _titleLabel;
}

-(UILabel *)statusLabel{
    if(!_statusLabel){
        _statusLabel = [UILabel lableWithText:@"" colorString:@"#5E8EF5" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _statusLabel;
}

-(UILabel *)valueLabel{
    if(!_valueLabel){
        _valueLabel = [UILabel lableWithText:@"" colorString:@"#5E8EF5" textFont:LGFont(16) textAlignment:NSTextAlignmentRight lines:1];
    }
    return _valueLabel;
}

@end
